package cn.tedu.charging.order.producer;

import cn.tedu.charging.common.constant.RabbitConstants;
import cn.tedu.charging.common.message.DelayMsg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RabbitProducer {
    @Autowired
    private RabbitTemplate template;

    //封装一个消息发送方法 发送的入参是消息数据对象
    public void send(DelayMsg delayMsg){
        log.info("订单下单发送延迟自检消息:{}",delayMsg);
        template.convertAndSend(
                RabbitConstants.CHARGING_EX,
                RabbitConstants.CHARGING_ROUTING_KEY,
                delayMsg);
        log.info("订单下单发送延迟自检消息:{},到交换机:{},路由key:{}",delayMsg,RabbitConstants.CHARGING_EX,RabbitConstants.CHARGING_ROUTING_KEY);
    }
}
